Desktop/Copy of GPS_TRACE/SRC/lcd.h

Go to the documentation of this file.
00001 #ifndef LCD_H
00002 #define LCD_H
00003 /*************************************************************************
00004  Title  :   C include file for the HD44780U LCD library (lcd.c)
00005  Author:    Peter Fleury <pfleury@gmx.ch>  http://jump.to/fleury
00006  File:      $Id: lcd.h,v 1.13.2.2 2006/01/30 19:51:33 peter Exp $
00007  Software:  AVR-GCC 3.3
00008  Hardware:  any AVR device, memory mapped mode only for AT90S4414/8515/Mega
00009 ***************************************************************************/
00010 
00035 
00036 #if (__GNUC__ * 100 + __GNUC_MINOR__) < 303
00037 #error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !"
00038 #endif
00039 
00040 #include <inttypes.h>
00041 #include <avr/pgmspace.h>
00042 
00047 #define XTAL 4000000              
00054 #define LCD_CONTROLLER_KS0073 0  
00060 #define LCD_LINES           4     
00061 #define LCD_DISP_LENGTH    20     
00062 #define LCD_LINE_LENGTH  0x40     
00065 #define LCD_START_LINE1  0x00     
00066 #define LCD_START_LINE2  0x14     
00067 #define LCD_START_LINE3  0x40     
00068 #define LCD_START_LINE4  0x54     
00072 //#define LCD_START_LINE1  0x00     
00073 //#define LCD_START_LINE2  0x40     
00074 //#define LCD_START_LINE3  0x14     
00075 //#define LCD_START_LINE4  0x54     
00076 #define LCD_WRAP_LINES      0     
00079 #define LCD_IO_MODE      1         
00080 #if LCD_IO_MODE
00081 
00095 #define LCD_PORT         PORTA        
00096 #define LCD_DATA0_PORT   LCD_PORT     
00097 #define LCD_DATA1_PORT   LCD_PORT     
00098 #define LCD_DATA2_PORT   LCD_PORT     
00099 #define LCD_DATA3_PORT   LCD_PORT     
00100 #define LCD_DATA0_PIN    0            
00101 #define LCD_DATA1_PIN    1            
00102 #define LCD_DATA2_PIN    2            
00103 #define LCD_DATA3_PIN    3            
00104 #define LCD_RS_PORT      LCD_PORT     
00105 #define LCD_RS_PIN       4            
00106 #define LCD_RW_PORT      LCD_PORT     
00107 #define LCD_RW_PIN       5            
00108 #define LCD_E_PORT       LCD_PORT     
00109 #define LCD_E_PIN        6            
00111 #elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
00112       defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
00113       defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
00114 /*
00115  *  memory mapped mode is only supported when the device has an external data memory interface
00116  */
00117 #define LCD_IO_DATA      0xC000    /* A15=E=1, A14=RS=1                 */
00118 #define LCD_IO_FUNCTION  0x8000    /* A15=E=1, A14=RS=0                 */
00119 #define LCD_IO_READ      0x0100    /* A8 =R/W=1 (R/W: 1=Read, 0=Write   */
00120 #else
00121 #error "external data memory interface not available for this device, use 4-bit IO port mode"
00122 
00123 #endif
00124 
00125 
00132 /* instruction register bit positions, see HD44780U data sheet */
00133 #define LCD_CLR               0      /* DB0: clear display                  */
00134 #define LCD_HOME              1      /* DB1: return to home position        */
00135 #define LCD_ENTRY_MODE        2      /* DB2: set entry mode                 */
00136 #define LCD_ENTRY_INC         1      /*   DB1: 1=increment, 0=decrement     */
00137 #define LCD_ENTRY_SHIFT       0      /*   DB2: 1=display shift on           */
00138 #define LCD_ON                3      /* DB3: turn lcd/cursor on             */
00139 #define LCD_ON_DISPLAY        2      /*   DB2: turn display on              */
00140 #define LCD_ON_CURSOR         1      /*   DB1: turn cursor on               */
00141 #define LCD_ON_BLINK          0      /*     DB0: blinking cursor ?          */
00142 #define LCD_MOVE              4      /* DB4: move cursor/display            */
00143 #define LCD_MOVE_DISP         3      /*   DB3: move display (0-> cursor) ?  */
00144 #define LCD_MOVE_RIGHT        2      /*   DB2: move right (0-> left) ?      */
00145 #define LCD_FUNCTION          5      /* DB5: function set                   */
00146 #define LCD_FUNCTION_8BIT     4      /*   DB4: set 8BIT mode (0->4BIT mode) */
00147 #define LCD_FUNCTION_2LINES   3      /*   DB3: two lines (0->one line)      */
00148 #define LCD_FUNCTION_10DOTS   2      /*   DB2: 5x10 font (0->5x7 font)      */
00149 #define LCD_CGRAM             6      /* DB6: set CG RAM address             */
00150 #define LCD_DDRAM             7      /* DB7: set DD RAM address             */
00151 #define LCD_BUSY              7      /* DB7: LCD is busy                    */
00152 
00153 /* set entry mode: display shift on/off, dec/inc cursor move direction */
00154 #define LCD_ENTRY_DEC            0x04   /* display shift off, dec cursor move dir */
00155 #define LCD_ENTRY_DEC_SHIFT      0x05   /* display shift on,  dec cursor move dir */
00156 #define LCD_ENTRY_INC_           0x06   /* display shift off, inc cursor move dir */
00157 #define LCD_ENTRY_INC_SHIFT      0x07   /* display shift on,  inc cursor move dir */
00158 
00159 /* display on/off, cursor on/off, blinking char at cursor position */
00160 #define LCD_DISP_OFF             0x08   /* display off                            */
00161 #define LCD_DISP_ON              0x0C   /* display on, cursor off                 */
00162 #define LCD_DISP_ON_BLINK        0x0D   /* display on, cursor off, blink char     */
00163 #define LCD_DISP_ON_CURSOR       0x0E   /* display on, cursor on                  */
00164 #define LCD_DISP_ON_CURSOR_BLINK 0x0F   /* display on, cursor on, blink char      */
00165 
00166 /* move cursor/shift display */
00167 #define LCD_MOVE_CURSOR_LEFT     0x10   /* move cursor left  (decrement)          */
00168 #define LCD_MOVE_CURSOR_RIGHT    0x14   /* move cursor right (increment)          */
00169 #define LCD_MOVE_DISP_LEFT       0x18   /* shift display left                     */
00170 #define LCD_MOVE_DISP_RIGHT      0x1C   /* shift display right                    */
00171 
00172 /* function set: set interface data length and number of display lines */
00173 #define LCD_FUNCTION_4BIT_1LINE  0x20   /* 4-bit interface, single line, 5x7 dots */
00174 #define LCD_FUNCTION_4BIT_2LINES 0x28   /* 4-bit interface, dual line,   5x7 dots */
00175 #define LCD_FUNCTION_8BIT_1LINE  0x30   /* 8-bit interface, single line, 5x7 dots */
00176 #define LCD_FUNCTION_8BIT_2LINES 0x38   /* 8-bit interface, dual line,   5x7 dots */
00177 
00178 
00179 #define LCD_MODE_DEFAULT     ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC) )
00180 
00181 
00182 
00196 extern void lcd_init(uint8_t dispAttr);
00197 
00198 
00204 extern void lcd_clrscr(void);
00205 
00206 
00212 extern void lcd_home(void);
00213 
00214 
00222 extern void lcd_gotoxy(uint8_t x, uint8_t y);
00223 
00224 
00230 extern void lcd_putc(char c);
00231 
00232 
00238 extern void lcd_puts(const char *s);
00239 
00240 
00247 extern void lcd_puts_p(const char *progmem_s);
00248 
00249 
00255 extern void lcd_command(uint8_t cmd);
00256 
00257 
00265 extern void lcd_data(uint8_t data);
00266 
00267 
00271 #define lcd_puts_P(__s)         lcd_puts_p(PSTR(__s))
00272 
00274 #endif //LCD_H

Generated on Fri Aug 17 13:50:54 2007 for GPS TRACE by  doxygen 1.5.3